﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TodoUser.Adapters.Interfaces;
using TodoUser.Models;
using TodoUser.Data;

namespace TodoUser.Adapters.Adapters
{
    public class UserAdapter : IUserAdapter
    {
        public UserVM GetUserInfo(string userId)
        {
            UserVM user;
            using(ApplicationDbContext db = new ApplicationDbContext()){
                user = db.Users.Where(x => x.Id == userId)
                    .Select(x => new UserVM {
                        Username = x.UserName,
                        Email = x.Email
                    }).FirstOrDefault();
            }
            return user;
        }
    }
}